package job

import "github.com/robfig/cron/v3"

type CronJobBuilder struct {
}

func NewCronJobBuilder() *CronJobBuilder {
	return &CronJobBuilder{}
}

func (builder *CronJobBuilder) Build(job Job) cron.Job {
	return (cronJobAdapterFunc)(func() error {
		return job.Run()
	})
}

// cronJobAdapterFunc cron接口适配器
type cronJobAdapterFunc func() error

func (f cronJobAdapterFunc) Run() {
	_ = f()
}
